/*   **********************************************************************  **
 **   Copyright notice                                                       **
 **                                                                          **
 **   (c) 2009, Around(J2)ME				                                 **
 **   All rights reserved.                                                   **
 **                                                                          **
 **   This program and the accompanying materials are made available under   **
 **   the terms of the New BSD License which accompanies this    			 **
 **   distribution.											                 **
 **   A copy is found in the textfile LICENSE.txt							 **
 **                                                                          **
 **   This copyright notice MUST APPEAR in all copies of the file!           **
 **                                                                          **
 **   Main developers:                                                       **
 **     Juri Strumpflohner		http://blog.js-development.com	             **
 **		Matthias Braunhofer		http://matthias.jimdo.com                    **
 **                                                                          **
 **  **********************************************************************  */

package com.aroundj2me.utility;

import java.io.IOException;

import javax.microedition.lcdui.Image;

/**
 * Usage: 1st the new image has to be declared in the ImageLoader class: public
 * static String MY_NEW_IMG = "/<imagename>.<extension>";
 * 
 * The class which wants to load the Image then has just to call:
 * ImageLoader.getImage(ImageLoader.MY_NEW_IMG);
 * 
 */
public class ImageLoader {
	public static String SPLASH_SCREEN = "/splash.png";
	public static String DB_DOWNLOAD = "/db_download.png";
	public static String DB_DOWNLOADED = "/db_downloaded.png";

	public static String CATEGORIES = "/categories.png";
	public static String GLOBE = "/globe.png";
	public static String GLOBSEARCH = "/globesearch.png";
	public static String MAP = "/map.png";

	public static String WARNING = "/warning.png";

	public static String SEARCH = "/search.png";
	public static String NEARBY_PLACES = "/nearby_places.png";
	public static String MANAGE_PLACEDATA = "/data_settings.png";
	public static String INFO = "/info.png";
	public static String ABOUT = "/about.png";

	/**
	 * Static method which loads the images
	 * 
	 * @param name
	 * @return
	 */
	public static Image getImage(String name) {
		Image img = null;
		try {
			img = Image.createImage(name);
		} catch (IOException e) {
			System.out.println("Unable to load " + name);
		}
		return img;
	}

	/**
	 * Loads the image of a specific category. The image must match the category
	 * name to be found, i.e. for category "Gas Station" there has to be an
	 * image "Gas Station.png"
	 * 
	 * @param catName
	 * @return
	 */
	public static Image getCategoryImage(String catName) {
		Image img = null;
		try {
			img = Image.createImage("/" + catName + ".png");
		} catch (IOException e) {
			System.out.println("Unable to load " + catName);
		}
		return img;
	}

}
